#!/bin/bash

start() {
    for i in /userdata/system/wireguard/*.conf ;do
        wg-quick up "$i"
    done
}

stop() {
    for i in $(ls -r /userdata/system/wireguard/*.conf) ;do
        wg-quick down "$i"
    done
}

restart() {
    stop
    start
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        ;;
esac
